package com.yunpuvip.sachet.modular.core.exception;


/**
 * rest模块自定义业务异常
 *
 * @Author: hyf
 * @Date: 2018/7/16
 **/
public class RestException extends RuntimeException {

    private Boolean success = false;

    private Integer code;

    private String message;

    private String exceptionStr;

    public RestException(RestServiceExceptionEnum restServiceExceptionEnum) {
        this.code = restServiceExceptionEnum.getCode();
        this.message = restServiceExceptionEnum.getMessage();

    }

    public RestException(Integer errorCode, String errorMsg) {
        this.code = errorCode;
        this.message = errorMsg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getExceptionStr() {
        return exceptionStr;
    }

    public void setExceptionStr(String exceptionStr) {
        this.exceptionStr = exceptionStr;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public static RestException createRestException(RestServiceExceptionEnum restServiceExceptionEnum) {
        return new RestException(restServiceExceptionEnum);
    }

    public static RestException createRestException(Integer code, String msg) {
        return new RestException(code, msg);
    }
}
